function random() {
    return Math.random() * 2 - 1
}
function createGeometry(amount, step) {
    var vertices = [];
    for (var i = 400; i < amount; i += step) {
        var angle = i / 1400;
        var distance = i / 600;
        var progress = ( i / amount ) * 4 + 0.5;
        vertices.push(progress * random() * random() + Math.sin(angle) * distance, progress * random() * random(), progress * random() * random() + Math.cos(angle) * distance);
    }
    var geometry = new THREE.BufferGeometry();
    geometry.addAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
    return geometry;
}
function createTexture(from, to) {
    var canvas = document.createElement('canvas');
    canvas.width = 16;
    canvas.height = 16;
    var context = canvas.getContext('2d');
    var gradient = context.createRadialGradient(8, 8, 0, 8, 8, 8);
    gradient.addColorStop(0, from);
    gradient.addColorStop(1, to);
    context.fillStyle = gradient;
    context.fillRect(0, 0, canvas.width, canvas.height);
    return new THREE.CanvasTexture(canvas);
}
var geometry = createGeometry(20000, 40);
var material = new THREE.PointsMaterial({
    size: 4,
    map: createTexture('rgba(0,0,15,1)', 'rgba(0,0,0,0)'),
    depthWrite: false,
    transparent: true
});
var points = new THREE.Points(geometry, material);
this.add(points);
var geometry = createGeometry(20000, 40);
var material = new THREE.PointsMaterial({
    size: 4,
    map: createTexture('rgba(15,0,15,1)', 'rgba(0,0,0,0)'),
    depthWrite: false,
    transparent: true
});
var points = new THREE.Points(geometry, material);
points.rotation.y = Math.PI;
this.add(points);
var geometry = createGeometry(20000, 8);
var material = new THREE.PointsMaterial({
    size: 0.4,
    map: createTexture('rgba(255,405,255,1)', 'rgba(0,0,0,0)'),
    blending: THREE.AdditiveBlending,
    depthWrite: false,
    transparent: true
});
var points = new THREE.Points(geometry, material);
this.add(points);
var geometry = createGeometry(20000, 8);
var material = new THREE.PointsMaterial({
    size: 0.4,
    map: createTexture('rgba(255,255,400,1)', 'rgba(0,0,0,0)'),
    blending: THREE.AdditiveBlending,
    depthWrite: false,
    transparent: true
});




var points = new THREE.Points(geometry, material);
points.rotation.y = Math.PI;
this.add(points);









var geometry = createGeometry(20000, 0.4);
var material = new THREE.PointsMaterial({
    size: 0.25,
    map: createTexture('rgba(405,405,255,1)', 'rgba(0,0,0,0)'),
    blending: THREE.AdditiveBlending,
    depthWrite: false,
    transparent: true
});
var points = new THREE.Points(geometry, material);
this.add(points);
var geometry = createGeometry(20000, 0.4);
var material = new THREE.PointsMaterial({
    size: 0.25,
    map: createTexture('rgba(255,400,255,1)', 'rgba(0,0,0,0)'),
    blending: THREE.AdditiveBlending,
    depthWrite: false,
    transparent: true
});
var points = new THREE.Points(geometry, material);
points.rotation.y = Math.PI;
this.add(points);
